package com.rizzo.analytics.domain.trigger;

public enum TresholdType {

    MIN("min"),
    MAX("max"),
    MEAN("mean"),
    DEVIATION("deviation"),
    HITS("hits"),
    QUOTA("quota");

    private String prefix;

    TresholdType(String prefix) {
        this.prefix = prefix;
    }

    public String getPrefix() {
        return prefix;
    }

    public static TresholdType fromPrefix(String token) {
        for (TresholdType c : TresholdType.values()) {
            if (c.prefix.equals(token)) {
                return c;
            }
        }
        throw new IllegalArgumentException("'" + token + "' could not be converted to a TresholdType!");
    }

    public static boolean isTresholdType(String prefix) {
        for (TresholdType c : TresholdType.values()) {
            if (c.prefix.equals(prefix)) {
                return true;
            }
        }
        return false;
    }

}
